#include<iostream>
#include<cmath>
using namespace std;
const int N = 1e3 + 10;
char g[N][N];
int n, m;
int num(int a, int b, int c, int d) {
	return abs(a - c) + abs(b - d);
}
int main()
{
	cin >> n >> m;
	int x, y;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> g[i][j];
		}
	}
	int ans = 0;
	int maxn = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (g[i][j] == '#') {
				// cout << i << ' ' << j << endl;
				// cout << num(1, 1, i, j) << ' ' << num(1, m, i, j) << ' ' << num(n, 1, i, j) << ' ' << num(n, m, i, j) << endl;
				maxn = max(maxn, num(1, 1, i, j));
				maxn = max(maxn, num(1, m, i, j));
				maxn = max(maxn, num(n, 1, i, j));
				maxn = max(maxn, num(n, m, i, j));
			}
		}
	}
	cout << maxn << endl;
	return 0;
}